import React from 'react'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {actions} from '../../reducers'
import {actions as ProjectAction} from '../../reducers/project'
import utils from '../../common/utils'

class PointIncome extends React.Component {
  componentDidMount() {
    
  }
    render() {
      const {number, content, user_point, project_user } = this.props.project,
          userInfo = this.props.userInfo,
          role = utils.getQueryString('type')
        return(
          <div class="tabs-point-income">
            <p>
              {
                user_point.filter(x => x.user_id === userInfo.id).map( x =>
                  x.format_reason + '获得 ' + '+' + x.point + '积分'
                )
              }
            {/* 完成项目获得 +{user_point[0]&&user_point[0].point} 积分。 */}
            </p>
            {role=='execute'&&project_user ? 
              <p>
              完成项目获得 +{income} 收益
              </p>
              : null
            }
            
          </div>
        )
    }
}
function mapStateToProps(state) {
    return {
      project: state.project.detail,
      userInfo: state.user.userInfo
    }
  }
  
  function mapDispatchToProps(dispatch) {
    return  {
      get_project_detail: bindActionCreators(ProjectAction.get_detail, dispatch),
    }
  }
  
  export default connect(
    mapStateToProps,
    mapDispatchToProps
  )(PointIncome)